package com.zhoutao123.hephaestus.object.bussiness;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.github.pagehelper.PageInfo;
import com.zhoutao123.hephaestus.repository.entity.SysResources;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.util.List;

@EqualsAndHashCode(callSuper = true)
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class VSysResources extends PageBeanInfo implements Serializable {

    private List<SysResources> list;

    public static VSysResources of(PageInfo<SysResources> pageInfo) {
        VSysResources vSysResources = new VSysResources();
        vSysResources
                .setEndRow(pageInfo.getEndRow())
                .setStartRow(pageInfo.getStartRow())
                .setHasNextPage(pageInfo.isHasNextPage())
                .setHasPreviousPage(pageInfo.isHasPreviousPage())
                .setFristPage(pageInfo.isIsFirstPage())
                .setLastPage(pageInfo.isIsLastPage())
                .setNextPage(pageInfo.getNextPage())
                .setPrePage(pageInfo.getPrePage())
                .setPageNum(pageInfo.getPageNum())
                .setPageSize(pageInfo.getPageSize())
                .setTotal(pageInfo.getTotal())
                .setPages(pageInfo.getPages());
        vSysResources.setList(pageInfo.getList());
        return vSysResources;
    }
}
